const {
    Mysql
} = require('../tools/utils');
module.exports = async (ctx) => {
    let {
        uid
    } = ctx.query;
    if (uid != 'undefined') {
        let sql = `SELECT cSessionInfo.user_info,shareList.* FROM shareList RIGHT JOIN cSessionInfo ON shareList.receriver_uid=cSessionInfo.uid WHERE sharer_uid=${uid}`;
        let sql2 = `SELECT * FROM intergal WHERE uid = ${uid}`
        try {
            let list = await Mysql(sql);
            let total = await Mysql(sql2);
            ctx.state.data = {
                list,
                total: total.length ? total[0] : [],
                code: '001'
            }
        } catch (error) {
            ctx.state.data = {
                code: '002'
            }
        }
    } else {
        ctx.state.data = {
            code: '002'
        }
    }
}